package com.nbsaas.boot.project.rest.convert;

import com.nbsaas.boot.project.api.domain.simple.ProjectTaskMemberSimple;
import com.nbsaas.boot.project.data.entity.ProjectTaskMember;
import com.nbsaas.boot.rest.api.Converter;

/**
 * 任务参与人-列表对象转换器
 */

public class ProjectTaskMemberSimpleConvert implements Converter<ProjectTaskMemberSimple, ProjectTaskMember> {


    @Override
    public ProjectTaskMemberSimple convert(ProjectTaskMember source) {
        ProjectTaskMemberSimple result = new ProjectTaskMemberSimple();


        try {
            if (source.getTask() != null) {
                result.setTask(source.getTask().getId());
            }
        } catch (Exception ignored) {
        }

        if (source.getMemberType() != null) {
            result.setMemberTypeName(String.valueOf(source.getMemberType()));
        }
        result.setMemberType(source.getMemberType());
        result.setId(source.getId());

        try {
            if (source.getUser() != null) {
                result.setUser(source.getUser().getId());
            }
        } catch (Exception ignored) {
        }

        result.setAddDate(source.getAddDate());
        result.setLastDate(source.getLastDate());


        return result;
    }

}